<?php
namespace App\System\Http\Message;

class Response extends Message
{

    private $statusCode = 200;

    private $reasonPhrase = 'OK';

    private $cookies = [];

    public function getStatusCode()
    {
        // TODO: Implement getStatusCode() method.
        return $this->statusCode;
    }

    public function withStatus($code, $reasonPhrase = '')
    {
        // TODO: Implement withStatus() method.
        if ($code === $this->statusCode) {
            return $this;
        } else {
            $this->statusCode = $code;
            if (empty($reasonPhrase)) {
                $this->reasonPhrase = Status::getReasonPhrase($this->statusCode);
            } else {
                $this->reasonPhrase = $reasonPhrase;
            }
            return $this;
        }
    }

    public function getReasonPhrase()
    {
        // TODO: Implement getReasonPhrase() method.
        return $this->reasonPhrase;
    }

    function withAddedCookie(Cookie $cookie)
    {
        $this->cookies[] = $cookie;
        return $this;
    }

    function getCookies()
    {
        return $this->cookies;
    }
}